﻿using System;

namespace Test30.Engine
{
    [Flags]
    public enum GameResultFlags
    {
        Default        = 0x0000,
        NeedsPause     = 0x0001,
        NeedsUserInput = 0x0002,
        CheckForCancel = 0x0004,

        GameOver       = 0x0080
    }
    public class GameResult
    {
        public bool NeedsPause => IsFlagSet(GameResultFlags.NeedsPause);

        public bool NeedsAction => IsFlagSet(GameResultFlags.NeedsUserInput);
        public bool CheckForCancel => IsFlagSet(GameResultFlags.CheckForCancel);

        public bool IsGameOver => IsFlagSet(GameResultFlags.GameOver);
        public Entity Entity { get; }

        public GameResult(GameResultFlags flags, Entity entity)
        {
            _flags = flags;
            Entity = entity;
        }

        public GameResult(GameResultFlags flags) : this(flags, null)
        {
            _flags = flags;
        }

        public GameResult()
            : this(GameResultFlags.Default, null)
        {
        }

        private bool IsFlagSet(GameResultFlags flags)
        {
            return (_flags & flags) == flags;
        }

        private readonly GameResultFlags _flags;
    }
}
